package com.amkor.web.myhome.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.amkor.web.myhome.dao.EvaluationDao;
import com.amkor.web.myhome.domain.Evaluation;
import com.softwarementors.extjs.djn.config.annotations.DirectAction;
import com.softwarementors.extjs.djn.config.annotations.DirectMethod;

@DirectAction(action="Eval")
public class EvaluationServiceImpl implements EvaluationService {
	private EvaluationDao evalDao;
	
	public void setEvaluationDao(EvaluationDao evalDao){
		this.evalDao = evalDao;
	}	

	public Object getEvaluationRating(int empid, int cur_promote_dt, int limit_dt) throws Exception {		
		try{
			return validate(evalDao.getEvaluationRating(empid), cur_promote_dt, limit_dt);					
		}catch(Exception e){
			throw e;
		}		
	}
	
	private List<Evaluation> validate(List<Evaluation> list, int cur_promote_dt, int limit_dt){
		List<Evaluation> ret = new ArrayList<Evaluation>();
		for(Evaluation evaluation : list){
			if(Integer.valueOf(evaluation.getDate()) >= cur_promote_dt && Integer.valueOf(evaluation.getDate()) < limit_dt)
				ret.add(evaluation);
		}
		return ret;
	}
	
	@DirectMethod
	public String getEvaluation(Map<String, String> paramMap){
		return "eval ===>"+paramMap;
	}
}
